package com.lhkj.ct.base.json.databind;

import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * 用于BaseEum的子类解析成json格式，一般在api中注入此解析器
 * @author  Binz
 * 2019-05-27 11:29:02
 */
public class IEnumSerializer extends JsonSerializer<IEnum>{

    @Override
    public void serialize(IEnum value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        gen.writeObject(value.getValue());
    }

}
